package com.ayoka.mvp;

import com.ayoka.R;
import com.ayoka.base.BasePresenter;
import com.ayoka.base.IBaseView;
import com.ayoka.bean.BaseResponse;
import com.ayoka.bean.CourseBean;
import com.ayoka.bean.PagerBean;
import com.ayoka.bean.TrainingPackageBean;
import com.ayoka.http.API;
import com.ayoka.http.OkHttpListener;
import com.jcp.baselibrary.utils.UIUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by gabriel on 2017/3/5.
 */

public interface DoMVP {

    interface  DoModel {
    }

    interface IDoView extends IBaseView {

        void configTrainingPackageListData(List<TrainingPackageBean> listData);
    }

    class DoPresenter extends BasePresenter<IDoView> {


        public void getTrainingPackageListData(boolean isShowWaitDialog) {
            if (isShowWaitDialog) {
                mViewRef.get().showWaitDialog(UIUtils.getString(R.string.loading));
            }
            API.getTrainingPackageListData(this, new OkHttpListener<BaseResponse<List<TrainingPackageBean>>>() {
                @Override
                public void onSuccess(BaseResponse<List<TrainingPackageBean>> response) {
                    if (!isAttached()) return;
                    mViewRef.get().hideWaitDialog();
                    mViewRef.get().configTrainingPackageListData(response.data);
                }

                @Override
                public void onFailure(int errorCode, String errorMessage) {
                    if (!isAttached()) return;
                    mViewRef.get().hideWaitDialog();
                    mViewRef.get().showToast(errorMessage);
                }
            });
        }
    }

}
